package br.com.lazyprogrammer.worldsoccermanager.localization;

import android.content.Context;
import android.location.LocationManager;
import br.com.lazyprogrammer.worldsoccermanager.localization.exception.GPSNotAvailableException;

public class LocalizationFactoryDAO {

	
	public static LocalizationDAO create(Context context) throws GPSNotAvailableException {
		LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
		boolean networkEnable = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

		if (!networkEnable && !locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
			throw new GPSNotAvailableException();
		}
		
		return new LocalizationDAO();
	}
	
}
